package com.zhanggm.springcloud.user.controller;

import com.zhanggm.springcloud.user.pojo.User;
import com.zhanggm.springcloud.user.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user/")
public class UserController {
    @Autowired
    private UserService userService;

    @RequestMapping("getUserById")
    public User getUserById(@RequestParam("id") Integer id){
        User user = userService.getUserById(1);
        return user;
    }

    @RequestMapping("getUserNameByUser")
    public User getUserByUser(@RequestBody User user){
        User u = userService.getUserById(user.getId());
        return u;
    }
}
